package com.example.zcapi;

import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.Instrumentation;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.IBinder;
import android.os.RemoteException;
import android.view.KeyEvent;
import android.view.View;
import android.view.Window;
import android.widget.EditText;
import android.widget.Toast;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;

public class LockPassword extends Activity {
    public static LockPassword instance = null;
    List<String> recentList = new ArrayList<>(10);
    private Context mContext;
    private boolean start;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //StartDialog();
        instance = this;

    }


    private void ChangeDialog(){

        final View mView=getLayoutInflater().inflate(R.layout.change_password,null);
        final EditText old_passwork=mView.findViewById(R.id.old_password);
        final EditText new_passwork=mView.findViewById(R.id.new_password);
        final EditText confirm_passwork=mView.findViewById(R.id.confirm_password);

        new AlertDialog.Builder(this)
                .setTitle("修改密码")
                .setView(mView)
                .setPositiveButton("确定", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        if (old_passwork!=null && old_passwork.getText().toString().trim().equals("185799")){
                            if (new_passwork.getText().toString().trim().equals(confirm_passwork.getText().toString().trim())){

                                Toast.makeText(getApplicationContext(),"修改密码成功！",Toast.LENGTH_SHORT).show();
                            } else {
                                Toast.makeText(getApplicationContext(),"确认密码与新密码不一致，请重新输入！",Toast.LENGTH_SHORT).show();
                                dialog.dismiss();
                            }
                        } else {
                            Toast.makeText(getApplicationContext(),"原密码输入不正确，请重新输入！",Toast.LENGTH_SHORT).show();
                            dialog.dismiss();
                        }
                    }
                }).setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        }).create().show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
}
